home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / tests / bezout.dia.ref < prev    next >
Text File  |  1999-09-16  |  5KB  |  117 lines

  1.  
  2. //FICHIER_DE_TEST ADD NAME=bezout.tst,SSI=0
  3.  
  4. mode(5)
  5. //test
  6. un=poly(1,'s','c');
  7. zer=0*un;
  8. s=poly(0,'s');
  9. [p,q]=bezout(un,s);
  10. if norm(coeff([un s]*q-[p 0]))>10*%eps then bugmes();quit;end
  11. [p,q]=bezout(s,un);
  12. if norm(coeff([s un]*q-[p 0]))>10*%eps then bugmes();quit;end
  13. [p,q]=bezout(un,un);
  14. if norm(coeff([un un]*q-[p 0]))>10*%eps then bugmes();quit;end
  15. //
  16. [p,q]=bezout(zer,s);
  17. if norm(coeff([zer s]*q-[p 0]))>10*%eps then bugmes();quit;end
  18. [p,q]=bezout(s,zer);
  19. if norm(coeff([s zer]*q-[p 0]))>10*%eps then bugmes();quit;end
  20. [p,q]=bezout(zer,zer);
  21. if norm(coeff([zer zer]*q-[p 0]))>10*%eps then bugmes();quit;end
  22. //
  23. [p,q]=bezout(zer,un);
  24. if norm(coeff([zer un]*q-[p 0]))>10*%eps then bugmes();quit;end
  25. [p,q]=bezout(un,zer);
  26. if norm(coeff([un zer]*q-[p 0]))>10*%eps then bugmes();quit;end
  27. //
  28. //simple
  29. a=poly([1 2 3],'z');
  30. b=poly([4 1],'z');
  31. [p q]=bezout(a,b);
  32. dt=q(1,1)*q(2,2)-q(1,2)*q(2,1);dt0=coeff(dt,0);
  33. if norm(coeff(dt/dt0-1))>10*%eps then bugmes();quit;end
  34. qi=[q(2,2) -q(1,2);-q(2,1) q(1,1)]/dt0;
  35. if norm(coeff([p 0]*qi-[a b]))>100*%eps then bugmes();quit;end
  36. //more difficult
  37. b1=poly([4 1+1000*%eps],'z');del=10*norm(coeff(b1-b));
  38. [p,q]=bezout(a,b1);
  39. dt=q(1,1)*q(2,2)-q(1,2)*q(2,1);dt0=coeff(dt,0);
  40. if norm(coeff(dt/dt0-1))>del then bugmes();quit;end
  41. qi=[q(2,2) -q(1,2);-q(2,1) q(1,1)]/dt0;
  42. if norm(coeff([p 0]*qi-[a b1]))>del then bugmes();quit;end
  43. b1=poly([4 1+.001],'z');del=10*norm(coeff(b1-b));
  44. [p,q]=bezout(a,b1);
  45. dt=q(1,1)*q(2,2)-q(1,2)*q(2,1);dt0=coeff(dt,0);
  46. if norm(coeff(dt/dt0-1))>100000*%eps then bugmes();quit;end
  47. qi=[q(2,2) -q(1,2);-q(2,1) q(1,1)]/dt0;
  48. if norm(coeff([p 0]*qi-[a b1]))>100000*%eps then bugmes();quit;end
  49. b1=poly([4 1+10000*%eps],'z');del=10*norm(coeff(b1-b));
  50. [p,q]=bezout(a,b1);
  51. dt=q(1,1)*q(2,2)-q(1,2)*q(2,1);dt0=coeff(dt,0);
  52. if norm(coeff(dt/dt0-1))>del then bugmes();quit;end
  53. qi=[q(2,2) -q(1,2);-q(2,1) q(1,1)]/dt0;
  54. if norm(coeff([p 0]*qi-[a b1]))>del then bugmes();quit;end
  55. //
  56. z=poly(0,'z');
  57. num = 0.99999999999999922+z*(-4.24619123578530730+..
  58.       z*(10.0503215227460350+z*(-14.6836461849931740+..
  59.       z*(13.924822877119892+z*(-5.63165998008533460+..
  60.       z*(-5.63165998008530710+z*(13.9248228771198730+..
  61.       z*(-14.683646184993167+z*(10.0503215227460330+..
  62.       z*(-4.24619123578530910+z*(0.99999999999999989)))))))))));
  63. den = -0.17323463717888873+z*(1.91435457459735380+..
  64.       z*(-9.90126732768255560+z*(31.6286096652930410+..
  65.       z*(-69.3385546880304280+z*(109.586435800377690+..
  66.       z*(-127.516160100808290+z*(109.388684898145950+..
  67.       z*(-67.92645394857864+z*(29.1602681026148110+..
  68.       z*(-7.8212498781094952+z*(0.99999999999999989)))))))))));
  69. //
  70. [p,q]=bezout(num,den);del=1.d-4;
  71. dt=q(1,1)*q(2,2)-q(1,2)*q(2,1);dt0=coeff(dt,0);
  72. if norm(coeff(dt/dt0-1))>del then bugmes();quit;end
  73. qi=[q(2,2) -q(1,2);-q(2,1) q(1,1)]/dt0;
  74. // JPC
  75. del=3*del
  76.  del       =
  77.  
  78.     0.0003  
  79. if norm(coeff([p 0]*qi-[num den]))>del then bugmes();quit;end
  80. if degree(p)>0 then bugmes();quit;end
  81. // une autre "solution" telle que l'erreur directe est petite mais l'erreur
  82. // inverse grande
  83. q1=[]
  84.  q1        =
  85.  
  86.      []
  87. q1(1,1)=poly([0.011533588674 , 3.570224012502 , -28.78817740957 ,...
  88.             102.9479419903, -210.8258579715 , 266.2028963639 ,...
  89.            -207.427018299 , 92.74478640319, -18.5259652457],'z','c');
  90. q1(1,2)=poly([0.000270220664 , -0.002465565223 , 0.010039706635 ,...
  91.            -0.023913827007, 0.036387144032 , -0.036175176058 ,...
  92.             0.022954475171 , -0.008514798968,  0.001417382492],'z','c');
  93. q1(2,1)=poly([0.000639302018 , 20.502472606 , -26.66621972106 ,...
  94.             39.74001534015,  -5.945830824342 , -7.973226036298 ,...
  95.             39.84118622788 , -26.51337424414, 18.5259652457],'z','c');
  96. q1(2,2) =poly( [0.001562930385 , -0.003589174974 , 0.005076237479 ,...
  97.             -0.003483568682,  -0.000135940266 , 0.003651509121 ,...
  98.             -0.005059502869 , 0.003447573440, -0.001417382492],'z','c');
  99. p1 =poly( [0.011422839421 , -0.029264363070 , 0.030070175223 ,...
  100.          -0.012596066108],'z','c');
  101. //
  102. //simplification
  103. num =[0.03398330733500143,-0.20716057008572933,0.64660689206696986,...
  104.      -1.97665462134021790,3.38751027286891300,-3.58940006392108120,...
  105.       5.09956159043231680,5.2514918861834694,1.00000000000000020];
  106. den = [0.03398330733500360,-0.20716057008816283,0.64660689204312,...
  107.       -1.97665462079896660,3.38751027286891300,-3.58940006392108350,...
  108.        5.09956159043232040,5.2514918861834712,1];
  109. num=poly(num,'z','c');
  110. den=poly(den,'z','c');
  111. [p,q]=bezout(num,den);del=1.d-8;
  112. dt=q(1,1)*q(2,2)-q(1,2)*q(2,1);dt0=coeff(dt,0);
  113. if norm(coeff(dt/dt0-1))>del then bugmes();quit;end
  114. qi=[q(2,2) -q(1,2);-q(2,1) q(1,1)]/dt0;
  115. if norm(coeff([p 0]*qi-[num den]))>del then bugmes();quit;end
  116. if degree(p)<8 then bugmes();quit;end
  117.